<?php $this->set('title', 'Search Results'); ?>
<?php $this->set('external_css', array('surveys.css')); ?>
<?php $session->flash();?>
<div class="header">Search Surveys</div>
<!-- Search form -->
<?php echo $form->create('Survey', array('action' => 'search')); ?>
<table border="0" cellpadding=="0" cellspacing="0">
	<tr>
		<td class="leftcell">
			Name:
		</td>				
		<td class="rightcell">
			<?php echo($form->text('Survey.name', array('style' => 'width:200px;','value' => $searchName))); ?>
		</td>
	</tr>
	<tr>
		<td class="leftcell">
			Unique ID:
		</td>				
		<td class="rightcell">
			<?php echo($form->text('Survey.uuid', array('style' => 'width:200px;','value' => $searchUUID))); ?>
		</td>
	</tr>
	<tr>
		<td class="rightcell" colspan="2">
			<?php echo $form->end('Search') ?>
		</td>
	</tr>
</table>
<br />
<?php if($display) { ?>
<!-- Search results -->
<table style="" cellpadding="5" cellspacing="0" border="0">
	<tr> 
		<th><?php echo $paginator->sort('Name', 'name'); ?></th> 
		<th><?php echo $paginator->sort('Created', 'created'); ?></th>
		<th><?php echo $paginator->sort('Modified', 'modified'); ?></th>
		<th><?php echo $paginator->sort('Unique ID', 'uuid'); ?></th>
		<th>Register</th>
		<th>View</th>
	</tr>
    <?php foreach($surveys as $survey): ?> 
	<tr>
		<td><?php echo $survey['Survey']['name']; ?></td>
		<td><?php echo $survey['Survey']['created']; ?></td>
		<td><?php echo $survey['Survey']['modified']; ?></td>
		<td><?php echo substr($survey['Survey']['uuid'],1,8); ?></td>
		<td>
			<?php echo $html->link('Register',
		 	  array('controller'=>'users', 'action' => 'registerForSurvey', 'id' => $survey['Survey']['id'])); 
			 ?>
		 </td>
		 <td>
		 	<?php echo $html->link('View Survey',
			array('controller'=>'surveys', 'action'=>'user_view', 'id' => $survey['Survey']['id'], 1));
			?>&nbsp;
		 </td>
	</tr>
	<?php endforeach; ?>
	<tr>
		<!-- Pagination -->
		<td colspan="3">
			<!-- Shows the page numbers -->
			<?php echo $paginator->numbers(); ?>
			<br />
			<!-- Shows the next and previous links -->
			<?php
				echo $paginator->prev('« Previous ', null, null, array('class' => 'disabledPageLink'));
				echo $paginator->next(' Next »', null, null, array('class' => 'disabledPageLink'));
			?>
			<br />
			<!-- prints X of Y, where X is current page and Y is number of pages -->
			<?php echo $paginator->counter(); ?>
		</td>
	</tr>
</table>
<?php } ?>
<br /><br />